home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / WindowsTreeUI.java < prev    next >
Text File  |  1998-06-30  |  4KB  |  117 lines

  1. /*
  2.  * @(#)WindowsTreeUI.java    1.8 98/02/02
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20.  
  21. package com.sun.java.swing.plaf.windows;
  22.  
  23. import java.awt.*;
  24. import java.awt.event.*;
  25.  
  26. import java.io.*;
  27. import java.util.*;
  28.  
  29. import com.sun.java.swing.plaf.basic.*;
  30. import com.sun.java.swing.*;
  31. import com.sun.java.swing.plaf.*;
  32.  
  33.  
  34. /**
  35.  * A Windows tree.
  36.  * <p>
  37.  * Warning: serialized objects of this class will not be compatible with
  38.  * future swing releases.  The current serialization support is appropriate
  39.  * for short term storage or RMI between Swing1.0 applications.  It will
  40.  * not be possible to load serialized Swing1.0 objects with future releases
  41.  * of Swing.  The JDK1.2 release of Swing will be the compatibility
  42.  * baseline for the serialized form of Swing objects.
  43.  *
  44.  * @version 1.8 02/02/98
  45.  * @author unknown
  46.  */
  47. public class WindowsTreeUI extends BasicTreeUI {
  48.  
  49.     public static ComponentUI createUI( JComponent c )
  50.       {
  51.     return new WindowsTreeUI();
  52.       }
  53.  
  54.     protected void drawVerticalLine( Graphics g, JComponent c, int x, int top, int bottom )
  55.       {
  56.     drawDashedVerticalLine( g, x, top, bottom );
  57.       }
  58.  
  59.     protected void drawHorizontalLine( Graphics g, JComponent c, int y, int left, int right )
  60.       {
  61.     drawDashedHorizontalLine( g, y, left, right );
  62.       }
  63.  
  64.  
  65.     static protected final int HALF_SIZE = 4;
  66.     static protected final int SIZE = 9;
  67.  
  68.     /**
  69.      * The minus sign button icon
  70.      * <p>
  71.      * Warning: serialized objects of this class will not be compatible with
  72.      * future swing releases.  The current serialization support is appropriate
  73.      * for short term storage or RMI between Swing1.0 applications.  It will
  74.      * not be possible to load serialized Swing1.0 objects with future releases
  75.      * of Swing.  The JDK1.2 release of Swing will be the compatibility
  76.      * baseline for the serialized form of Swing objects.
  77.      */
  78.     public static class ExpandedIcon implements Icon, Serializable {
  79.         static public Icon createExpandedIcon() {
  80.         return new ExpandedIcon();
  81.     }
  82.  
  83.     public void paintIcon(Component c, Graphics g, int x, int y) {
  84.         g.setColor(Color.white);
  85.         g.fillRect(x, y, SIZE-1, SIZE-1);
  86.         g.setColor(Color.gray);
  87.         g.drawRect(x, y, SIZE-1, SIZE-1);
  88.         g.setColor(Color.black);
  89.         g.drawLine(x + 2, y + HALF_SIZE, x + (SIZE - 3), y + HALF_SIZE);
  90.     }
  91.     public int getIconWidth() { return SIZE; }
  92.     public int getIconHeight() { return SIZE; }
  93.     }
  94.  
  95.     /**
  96.      * The plus sign button icon
  97.      * <p>
  98.      * Warning: serialized objects of this class will not be compatible with
  99.      * future swing releases.  The current serialization support is appropriate
  100.      * for short term storage or RMI between Swing1.0 applications.  It will
  101.      * not be possible to load serialized Swing1.0 objects with future releases
  102.      * of Swing.  The JDK1.2 release of Swing will be the compatibility
  103.      * baseline for the serialized form of Swing objects.
  104.      */
  105.     public static class CollapsedIcon extends ExpandedIcon {
  106.         static public Icon createCollapsedIcon() {
  107.         return new CollapsedIcon();
  108.     }
  109.  
  110.     public void paintIcon(Component c, Graphics g, int x, int y) {
  111.         super.paintIcon(c, g, x, y);
  112.         g.drawLine(x + HALF_SIZE, y + 2, x + HALF_SIZE, y + (SIZE - 3));
  113.     }
  114.     }
  115.  
  116. }
  117.